import {
  Body,
  Headers,
  Controller,
  Get,
  Logger,
  Post,
  Render,
  Req,
  Res,
} from '@nestjs/common';
import { AppService } from './app.service';
import { Request, Response } from 'express';

@Controller()
export class AppController {
  constructor(private readonly appservice: AppService) {}

  @Get()
  @Render('index')
  async root() {
    return { msg: 'hello spider' };
  }

  @Post('/spiderRules')
  handleRules(@Body() body, @Headers() headers, @Req() req: Request, @Res() res: Response) {
    // Logger.log('body');
    // Logger.log(body);
    // Logger.log(req.query);
    // Logger.log(req.body);
    // Logger.log(headers);


    this.appservice.getDomStr();
    // console.log(JSON.parse(body));
    res.json({
      msg: '收到了',
    });
  }
}
